/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Database;

import java.sql.*;


public class Catalogue_Vender
{
    private int VenderId;
    private int CatalogueId;

    /**
     * @return the VenderId
     */
    public int getVenderId() {
        return VenderId;
    }

    /**
     * @param VenderId the VenderId to set
     */
    public void setVenderId(int VenderId) {
        this.VenderId = VenderId;
    }

    /**
     * @return the CatalogueId
     */
    public int getCatalogueId() {
        return CatalogueId;
    }

    /**
     * @param CatalogueId the CatalogueId to set
     */
    public void setCatalogueId(int CatalogueId) {
        this.CatalogueId = CatalogueId;
    }
    
    public boolean AddCV()
    {
        boolean kq = true;
        try
        {
            Connection con = ConecttoDatabase.getConnection();
            String query = "insert into Catalogue_Vender values(?, ?)";
            PreparedStatement ps = con.prepareStatement(query);
            ps.setInt(1,this.VenderId);
            ps.setInt(2,this.CatalogueId);
            
            kq = ps.executeUpdate() > 0;
        }
        catch(Exception ex)
        {
            System.out.println(ex);
            kq = false;
        }
        return kq;
    }
    
    public boolean EditCV()
    {
        boolean kq = true;
        try 
        {
            Connection con = ConecttoDatabase.getConnection();
            String query = "Update Catalogue_Vender set VenderId='"+this.VenderId+"' where CatalogueId='"+CatalogueId+"'";
            Statement st = con.createStatement();
            kq = st.executeUpdate(query)>0;
        }
        catch (Exception e)
        {
            System.out.println(e);
        }
        return kq;
    }
    
    public  boolean  DelCV()
    {
        boolean kq = true;
        try 
        {
            Connection con = ConecttoDatabase.getConnection();
            String query = "delete from Catalogue_Vender set CatalogueId='"+this.CatalogueId+"'";
            PreparedStatement ps =con.prepareStatement(query);
            kq = ps.executeUpdate()>0;
        }
        catch (Exception e) {
        kq = false;
        }
        return kq;
    }
    
}
